package br.org.bertol.mestrado.engine.optimisation.sls;

import java.util.ArrayList;

import br.org.bertol.mestrado.engine.Objective;
import br.org.bertol.mestrado.engine.optimisation.AbstractMetaHeuristica;
import br.org.bertol.mestrado.engine.optimisation.Operacao;
import br.org.bertol.mestrado.engine.optimisation.entity.AbstractUnit;
import br.org.bertol.mestrado.engine.optimisation.hillclimbing.HillClimbing;

/**
 * @author contaqualquer
 * @param <U>
 */
public abstract class AbstractStochasticLocalSearch<T, U extends AbstractUnit<T>>
        extends AbstractMetaHeuristica<T, U> {

    /***/
    protected final transient U                  startUnit;

    /***/
    protected transient U                        betterUnit;

    /***/
    protected final transient HillClimbing<T, U> hillClimbing;

    /**
     * @param verify
     *            Objeto verify
     * @param numIteracoes
     *            Máximo de iterações
     * @param sUnit
     *            Unidade inicial
     */
    @SuppressWarnings("unchecked")
    public AbstractStochasticLocalSearch(final long numIteracoes,
        final U sUnit, final ArrayList<T> classes, final Objective[] objectives) {

        super(numIteracoes, classes, objectives);

        this.startUnit = sUnit;

        hillClimbing = new HillClimbing<T, U>(null, 50, false,
                (Operacao<U>) SlsMovement.busca_local, null, null, classes,
                objectives);

    }

    /**
     * Retorna o a unidade com custo melhorado.
     * @return Unidade
     */
    public final U getBetterUnit() {
        return betterUnit;
    }

}